package lanqiao.dontaiguihua.moni;

import java.util.Scanner;

public class Lan2377 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int count=0;
        for(int i=0;i<5;i++){
            int x=sc.nextInt();
            int[] a=new int[4];
            int index=4;
            while(x!=0&&index!=0){
                a[index-1]=x%10;
                x/=10;
                index--;
            }
            if(a[0]==a[2]&&a[3]==a[1]+1){
                count++;
            }

        }
        System.out.println(count);
        sc.close();
    }
}
